import { Create, Update, Delete, Get, GetAll, GetTreeList,GetAllPermissions,ChangePassword } from '@/services/crud';
const CrudModel = {
    namespace: 'CrudModel',
    state: {
        response: {},
    },
    effects: {
        * get({ payload, control }, { call, put }) {
            const response = yield call(Get, payload, control);
            yield put({
                type: 'deal',
                payload: response,
            });
        },
        * getAll({ payload, control }, { call, put }) {
            const response = yield call(GetAll, payload, control);
            yield put({
                type: 'deal',
                payload: response,
            });
        },
        * update({ payload, control }, { call, put }) {
            const response = yield call(Update, payload, control);
            yield put({
                type: 'deal',
                payload: response,
            });
        },
        * create({ payload, control }, { call, put }) {
            const response = yield call(Create, payload, control);
            yield put({
                type: 'deal',
                payload: response,
            });
        },
        * delete({ payload, control }, { call, put }) {
            const response = yield call(Delete, payload, control);
            yield put({
                type: 'deal',
                payload: response,
            });
        },
        * getTreeList({ payload, control }, { call, put }) {
            const response = yield call(GetTreeList, payload, control);
            yield put({
                type: 'deal',
                payload: response,
            });
        },
        * getAllPermissions({ }, { call, put }) {
            const response = yield call(GetAllPermissions);
            yield put({
                type: 'deal',
                payload: response,
            });
        },
        * changePassword({ payload, control }, { call, put }) {
            const response = yield call(ChangePassword, payload, control);
            yield put({
                type: 'deal',
                payload: response,
            });
        },
    },
    reducers: {
        deal(state, action) {
            return { ...state, response: action.payload };
        },
    },
};
export default CrudModel;